﻿using System.Collections.Generic;
using System.Linq;
using Epam.PeopleInterfaces;
using JsonModel;
using jsonModel;


namespace Epam.BusinessLogic
{
    public class PeopleJsonService : IJsonPeopleService
    {
        public IRootJsonAdapter<IPeopleJsonAdapter> PeopleConvert(IEnumerable<IPeopleEntity> entitylist)
        {
            var list = from entity in entitylist
                       select new PeopleJsonAdapter(entity.Id, entity.Name,
                           entity.BirthDate.ToShortDateString(),
                           entity.Weight, entity.Height) as IPeopleJsonAdapter;
            return new RootAdapter<IPeopleJsonAdapter> { Root = list.ToList() };
        }

        public IRootJsonAdapter<IViewPeopleEntity> PeopleConvert(IEnumerable<IViewPeopleEntity> entities)
        {
            return new RootAdapter<IViewPeopleEntity>{Root = entities.ToList()};
        }
    }
}
